package com.globallogic.javatrainings.sergiiivanov.model;

/**
 * Abstract <b>UniversityException</b> covers exceptions that are used in the
 * application<br>
 * The purpose of this superclass is processing LOGs for debugging.<br>
 * 
 * @author Sergey
 * 
 */
public abstract class UniversityException extends Exception {
    private static final long serialVersionUID = 1L;
    /**
     * Enables writing of log file<br>
     * Turned on by command line parameter <code>-debug</code>
     */
    public static boolean debugEnabled = false;

    /**
     * Logs error if debug is enabled<br>
     * Calls {@link #writeLog(String)}
     * 
     */
    public UniversityException() {
        super();
        writeLog(Const.STRING_EMPTY);
    }

    /**
     * Logs error with provided message if debug is enabled<br>
     * Calls {@link #writeLog(String)}
     * 
     * @param message
     *            problem description
     */
    public UniversityException(String message) {
        super(message);
        writeLog(message);
    }

    /**
     * Writes log into <code>yyyy-mm-dd_h-m-s.log</code><br>
     * where <code>yyyy-mm-dd_h-m-s</code> is time when application started
     * 
     * @since next release
     * @param message
     */
    private void writeLog(String message) {
        if (debugEnabled) {
            // TODO logging system - next release
        }
    }
}
